home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
program
/
rcs5ap1s.lzh
/
CONF.SH
< prev
next >
Wrap
Linux/UNIX/POSIX Shell Script
|
1991-01-10
|
16KB
|
707 lines
#!/bin/sh
# Output RCS compile-time configuration.
Id='$Id: conf.sh,v 5.6 90/11/01 05:03:28 eggert Exp $'
# Copyright 1990 by Paul Eggert
# Distributed under license by the Free Software Foundation, Inc.
# This file is part of RCS.
#
# RCS is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 1, or (at your option)
# any later version.
#
# RCS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RCS; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Report problems and direct all questions to:
#
# rcs-bugs@cs.purdue.edu
# Direct standard output to "a.h"; later parts of this procedure need it.
# Standard error can be ignored if a.h is OK,
# and can be inspected for clues otherwise.
exec >a.h || exit
# The Makefile overrides the following defaults.
: ${C='cc -O'}
: ${COMPAT2=0}
: ${DIFF_FLAGS=-an}
: ${DIFF_L=1}
: ${RCSPREFIX=/usr/local/bin/}
: ${SENDMAIL=/usr/lib/sendmail}
: ${L=}
: ${DIFF=${RCSPREFIX}diff}
cat <<EOF || exit
/* RCS compile-time configuration */
/* $Id */
/*
* This file is generated automatically.
* If you edit it by hand your changes may be lost.
* Instead, please try to fix conf.sh,
* and send your fixes to rcs-bugs@cs.purdue.edu.
*/
EOF
: exitmain
cat >a.c <<EOF && $C a.c $L >&2 || exit
#include "a.h"
int main(argc,argv) int argc; char **argv; { return argc-1; }
EOF
e='(n) ? (exit(n),(n)) : (n) /* lint fodder */'
if ./a.out -
then :
elif ./a.out
then e=n
fi
echo "#define exitmain(n) return $e /* how to exit from main() */"
: standard includes
standardIncludes=
for h in stdio sys/types sys/stat fcntl limits stdlib string unistd vfork
do
cat >a.c <<EOF || exit
#include "a.h"
$standardIncludes
#include <$h.h>
int main(){ exitmain(0); }
EOF
if ($C a.c $L && ./a.out) >&2
then i="# include <$h.h>"
else
case $h in
string)
i='# include <strings.h>';;
*)
i=" /* #include <$h.h> does not work. */"
esac
fi || exit
standardIncludes="$standardIncludes
$i"
done
cat <<EOF || exit
#if !MAKEDEPEND$standardIncludes
#endif /* !MAKEDEPEND */
EOF
# has_sys_*_h
for H in dir param wait
do
: has_sys_${H}_h
cat >a.c <<EOF || exit
#include "a.h"
#include <sys/$H.h>
int main() { exitmain(0); }
EOF
if ($C a.c $L && ./a.out) >&2
then h=1
else h=0
fi
echo "#define has_sys_${H}_h $h /* Does #include <sys/$H.h> work? */"
done
: const, volatile
for i in const volatile
do
cat >a.c <<EOF || exit
# include "a.h"
$i int * $i * zero;
EOF
if $C -S a.c >&2
then echo "/* #define $i */ /* The '$i' keyword works. */"
else echo "#define $i /* The '$i' keyword does not work. */"
fi
done
# *_t
cat >a.c <<'EOF' || exit
#include "a.h"
#include <signal.h>
t x;
EOF
for t in gid_t mode_t pid_t sig_atomic_t size_t time_t uid_t
do
: $t
case $t in
time_t) i=long;;
*) i=int;;
esac
if $C -S -Dt=$t a.c >&2
then echo "/* typedef $i $t; */ /* Standard headers define $t. */"
else echo "typedef $i $t; /* Standard headers do not define $t. */"
fi
done
: has_prototypes
cat >a.c <<'EOF' || exit
#include "a.h"
int main(int, char**);
int main(int argc, char **argv) { exitmain(!argv[argc-1]); }
EOF
if $C -S a.c >&2
then h=1
else h=0
fi
cat <<EOF
#define has_prototypes $h /* Do function prototypes work? */
#if has_prototypes
# define P(params) params
# if !MAKEDEPEND
# include <stdarg.h>
# endif
# define vararg_start(ap,p) va_start(ap,p)
#else
# define P(params) ()
# if !MAKEDEPEND
# include <varargs.h>
# endif
# define vararg_start(ap,p) va_start(ap)
#endif
EOF
: has_getuid
cat >a.c <<'EOF' || exit
#include "a.h"
#ifndef getuid
uid_t getuid();
#endif
int main() { exitmain(getuid()!=getuid()); }
EOF
if ($C a.c $L && ./a.out) >&2
then h=1
else h=0
fi
echo "#define has_getuid $h /* Does getuid() work? */"
: declare_getpwuid
cat >a.c <<'EOF' || exit
#include "a.h"
#include <pwd.h>
d
int main() { exitmain(!getpwuid(0)); }
EOF
D='struct passwd *getpwuid P((uid_t));'
if ($C -Dd="$D" a.c $L && ./a.out) >&2
then define="#define declare_getpwuid $D"
elif ($C -Dd= a.c $L && ./a.out) >&2
then define="#define declare_getpwuid /* $D */"
else define="/* #define declare_getpwuid $D */"
fi
echo "$define"
: has_rename, bad_rename
cat >a.c <<'EOF' && rm -f a.d || exit
#include "a.h"
#ifndef rename
int rename();
#endif
int main() { exitmain(rename("a.c","a.d")); }
EOF
if ($C a.c $L && ./a.out && test -f a.d) >&2
then
h=1
echo x >a.c
if ./a.out && test ! -f a.c -a -f a.d
then b=0
else b=1
fi
else h=0 b=0
fi
echo "#define has_rename $h /* Does rename() work? */"
echo "#define bad_rename $b /* Does rename(A,B) fail if B exists? */"
: void, VOID
cat >a.c <<'EOF' || exit
#include "a.h"
void f() {}
int main() {f(); exitmain(0);}
EOF
if $C -S a.c >&2
then
v='(void) '
else
v=
echo 'typedef int void;'
fi
echo "#define VOID $v/* 'VOID e;' discards the value of an expression 'e'. */"
: signal_type, sig_zaps_handler
cat >a.c <<'EOF' || exit
#include "a.h"
#include <signal.h>
#ifndef getpid
pid_t getpid();
#endif
#ifndef kill
int kill();
#endif
#ifndef signal
signal_type (*signal P((int,signal_type(*)P((int)))))P((int));
#endif
signal_type nothing(i) int i; {}
int main(argc, argv) int argc; char **argv;
{
signal(SIGINT, nothing);
while (--argc)
kill(getpid(), SIGINT);
exitmain(0);
}
EOF
for signal_type in void int bad
do
case $signal_type in
bad) echo >&2 "cannot deduce signal_type"; exit 1
esac
($C -Dsignal_type=$signal_type a.c $L && ./a.out 1) >&2 && break
done
echo "#define signal_type $signal_type /* type returned by signal handlers */"
if ./a.out 1 2 >&2
then z=0
else z=1
fi
echo "#define sig_zaps_handler $z /* Must a signal handler reinvoke signal()? */"
: has_seteuid
cat >a.c <<'EOF' || exit
#include "a.h"
#ifndef geteuid
uid_t geteuid();
#endif
int main() {
/* Guess, don't test. Ugh. Testing would require running conf.sh setuid. */
#if !_POSIX_VERSION || _POSIX_VERSION==198808L&&!defined(sun)&&!defined(__sun__)
exitmain(1);
#else
exitmain(seteuid(geteuid()) < 0);
#endif
}
EOF
if ($C a.c $L && ./a.out) >&2
then h=1
else h=0
fi
echo "#define has_seteuid $h /* Does seteuid() obey Posix 1003.1-1990? */"
: has_sigaction
cat >a.c <<'EOF' || exit
#include <signal.h>
struct sigaction s;
EOF
if $C -S a.c >&2
then h=1
else h=0
fi
echo "#define has_sigaction $h /* Does struct sigaction work? */"
: has_sigblock
cat >a.c <<'EOF' || exit
#include "a.h"
#include <signal.h>
#ifndef sigblock
int sigblock();
#endif
int main() { sigblock(0); exitmain(0); }
EOF
if ($C a.c $L && ./a.out) >&2
then h=1
else h=0
fi
echo "#define has_sigblock $h /* Does sigblock() work? */"
: has_sys_siglist
cat >a.c <<'EOF' || exit
#include "a.h"
#ifndef sys_siglist
extern const char *sys_siglist[];
#endif
int main() { exitmain(!sys_siglist[1][0]); }
EOF
if ($C a.c $L && ./a.out) >&2
then h=1
else h=0
fi
echo "#define has_sys_siglist $h /* Does sys_siglist[] work? */"
: exit_type, underscore_exit_type
cat >a.c <<'EOF' || exit
#include "a.h"
#ifndef exit
void exit();
#endif
int main() { exit(0); }
EOF
if $C -S a.c >&2
then t=void
else t=int
fi
echo "#define exit_type $t /* type returned by exit() */"
cat >a.c <<'EOF' || exit
#include "a.h"
#ifndef _exit
void _exit();
#endif
int main() { _exit(0); }
EOF
if $C -S a.c >&2
then t=void
else t=int
fi
echo "#define underscore_exit_type $t /* type returned by _exit() */"
: fread_type
cat >a.c <<'EOF' || exit
#include "a.h"
#ifndef fread
size_t fread();
#endif
int main() { char b; exit